Last Update: 2025/3/26
Kling Text to Video API
The Text to Video API enables you to create video content from text descriptions using Kling's AI models. This document provides details about the API endpoint, parameters, and response structure.
Endpoint
POST https://platform.llmprovider.ai/v1/videos/text2video
Request Headers
Header | Value |
---|---|
Authorization | Bearer YOUR_API_KEY |
Content-Type | application/json |
Request Body
The request body should be a JSON object with the following parameters:
Field | Type | Description |
---|---|---|
model | string | The model to use. Options: kling-video-v1 , kling-video-v1-6 |
prompt | string | Text prompt for video generation (max 2500 characters). |
negative_prompt | string | (Optional) Negative text prompt (max 2500 characters). |
cfg_scale | float | (Optional) Generation freedom scale [0, 1]. Higher values mean stricter adherence to prompt. Default: 0.5 |
mode | string | (Optional) Generation mode. Options: std (standard), pro (professional quality). Default: std |
camera_control | object | (Optional) Camera movement controls. Optional |
aspect_ratio | string | (Optional) Video aspect ratio. Options: 16:9 , 9:16 , 1:1 . Default: 16:9 |
duration | string | (Optional) Video duration in seconds. Options: 5 , 10 . Default: 5 |
external_task_id | string | (Optional) Custom task identifier. Optional |
Camera Control Object
Field | Type | Description |
---|---|---|
type | string | Camera movement type: simple , down_back , forward_up , right_turn_forward , left_turn_forward |
config | object | Camera configuration (required when type is simple ) |
Camera Config Object
All fields are optional with range [-10, 10]:
horizontal
: Horizontal movementvertical
: Vertical movementpan
: Horizontal rotation (Y-axis)tilt
: Vertical rotation (X-axis)roll
: Roll rotation (Z-axis)zoom
: Zoom level change
Example Request
{
"model": "kling-video-v1",
"prompt": "A beautiful sunset over the ocean",
"camera_control": {
"type": "simple",
"config": {
"pan": 1
}
}
}
Response Body
The API returns a JSON object with the following structure:
Field | Type | Description |
---|---|---|
task_id | string | Generated task identifier |
task_info | object | Task creation parameters |
task_status | string | Task status: submitted , processing , succeed , failed |
created_at | integer | Task creation timestamp (milliseconds) |
updated_at | integer | Last update timestamp (milliseconds) |
Example Response
{
"task_id": "task_xyz789",
"task_info": {
"external_task_id": "custom_id_123"
},
"task_status": "submitted",
"created_at": 1722769557708,
"updated_at": 1722769557708
}
Example Request
- Shell
- nodejs
- python
curl -X POST https://platform.llmprovider.ai/v1/videos/text2video \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-video-v1",
"prompt": "A beautiful sunset over the ocean",
"camera_control":{
"type": "simple",
"config":{
"pan": 1
}
}
}'
const axios = require('axios');
const apiKey = 'YOUR_API_KEY';
const url = 'https://platform.llmprovider.ai/v1/videos/text2video';
const data = {
model: 'kling-video-v1',
prompt: 'A beautiful sunset over the ocean',
camera_control:{
"type": "simple",
"config":{
"pan": 1
}
}
};
const headers = {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
};
axios.post(url, data, { headers })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error);
});
import requests
import json
api_key = 'YOUR_API_KEY'
url = 'https://platform.llmprovider.ai/v1/videos/text2video'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
'model': 'kling-video-v1',
'prompt': 'A beautiful sunset over the ocean',
'camera_control': {
'type': 'simple',
'config': {
'pan': 1
}
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print('Response:', response.json())
else:
print('Error:', response.status_code, response.text)
For any questions or further assistance, please contact us at [email protected].